[Repo Assist] Add MarkdownProvider type provider#1661
Closed
github-actions[bot] wants to merge 2 commits intomainfrom
Closed
[Repo Assist] Add MarkdownProvider type provider#1661github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
…ter in Markdown files - Add MarkdownDocument runtime type (FSharp.Data.Json.Core) implementing IJsonDocument with a minimal YAML-lite front matter parser and Body property - Add MarkdownProvider design-time type provider (FSharp.Data.DesignTime) reusing existing JSON inference and type-generation infrastructure - Add sample data file (BlogPost.md) and design-time signature test - Add integration tests for MarkdownProvider - Add documentation (docs/library/MarkdownProvider.fsx) - Update RELEASE_NOTES.md Closes #1657 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Great job but the use cases are not so compelling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist.
Implements a
MarkdownProvidertype provider that gives statically typed access to YAML front matter in Markdown files, as requested in #1657.What this adds
Implementation
src/FSharp.Data.Json.Core/MarkdownDocument.fs(new)MarkdownDocumenttype that implementsIJsonDocument, carrying both the front-matterJsonValueand theBodystringFrontMatterParserinternal module: minimal YAML-lite parser supporting strings, numbers, booleans, null, inline arrays[a, b, c], and block arrays (- itemstyle)MarkdownDocument.Load(TextReader)andMarkdownDocument.ParseSample(string)static methodssrc/FSharp.Data.DesignTime/Markdown/MarkdownProvider.fs(new)MarkdownProvidertype provider registered asFSharp.Data.MarkdownProviderJsonValue.Record→ runs through existingJsonInference+JsonTypeBuilderBody: stringproperty to the root generated type (viaIJsonDocument :?> MarkdownDocumentdowncast — safe becauseCreateFromTextReaderalways produces aMarkdownDocument)Sample,RootName,Culture,Encoding,ResolutionFolder,EmbeddedResource,InferTypesFromValues,UseOriginalNames,PreferOptionalsTests & docs
tests/FSharp.Data.Tests/Data/BlogPost.md— sample filetests/FSharp.Data.DesignTime.Tests/expected/Markdown,BlogPost.md,,True.expected— signature snapshottests/FSharp.Data.Tests/MarkdownProvider.fs— integration tests (7 test cases)docs/library/MarkdownProvider.fsx— documentationDesign decisions
With*methods, andInferenceModesupport come for free.Bodyproperty is added to the root type after JSON type generation, giving access to the markdown content below the front matter.Supported front matter patterns
key: valuestringkey: 42intkey: 3.14decimalkey: true/falseboolkey: 2024-01-15System.DateTimekey: [a, b, c]string[]key: null/~T option- itemstring[]Test Status
✅ Build succeeded
⚠️
✅ 488 design-time tests pass (including new Markdown signature test)
FSharp.Data.TestsOOM on CI runner — pre-existing infrastructure constraint (confirmed by checking out main and observing the same failure without my changes)Closes #1657